package com.mhr.bike;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.amap.api.maps.AMap;
import com.amap.api.maps.AMapOptions;
import com.amap.api.maps.CameraUpdate;
import com.amap.api.maps.CameraUpdateFactory;
import com.amap.api.maps.MapView;
import com.amap.api.maps.model.CameraPosition;
import com.amap.api.maps.model.Gradient;
import com.amap.api.maps.model.HeatmapTileProvider;
import com.amap.api.maps.model.LatLng;
import com.amap.api.maps.model.Marker;
import com.amap.api.maps.model.MarkerOptions;
import com.amap.api.maps.model.MyLocationStyle;
import com.amap.api.maps.model.TileOverlayOptions;

import java.util.Arrays;
import java.util.List;
public class findmaps extends Activity {
    private MapView mapView = null;
    int a=0;
    AMap maps;
    LatLng latLng;
    private LinearLayout.LayoutParams mParams;
    private RelativeLayout mContainerLayout;

    public  static  final  String LOC="location";
    public  static  final int deji=0;
    public  static  final int xuehui=1;
    public  static  final int baichuan=2;
    public  static  final int sihai=3;
    public  static  final int tiyu=4;
    public  static  final int yangfan=5;
    public  static  final int zonghe=6;
    public  static  final int yinghua=7;
    public  static  final int tushu=8;
    public  static  final int xiaomen=9;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_findmaps);
        mapView = (MapView) findViewById(R.id.finds);
        int locationIndex = getIntent().getIntExtra(LOC,0);
        switch (locationIndex){
            case deji:
                latLng=new LatLng(38.86750, 121.527830);
                break;
            case xuehui:
                latLng=new LatLng( 38.868720403847014 ,121.52764204662705);
                break;
            case baichuan:
                latLng=new LatLng(38.86750, 121.527030);
                break;
            case sihai:
                latLng=new LatLng(38.86700, 121.528300);
                break;
            case tiyu:
                latLng=new LatLng(38.86943424737326, 121.52553285803606);
                break;
            case yangfan:
                latLng=new LatLng(38.865775435789054 ,121.52874078001787);
                break;
            case zonghe:
                latLng=new LatLng(38.870662162482624 ,121.53519685711672);
                break;
            case yinghua:
                latLng=new LatLng(38.871150816674174, 121.52226860966493);
                break;
            case tushu:
                latLng=new LatLng(38.86932565522131 , 121.52683372940828);
                break;
            case xiaomen:
                latLng=new LatLng(38.86707441899689 ,121.53460140671541);
                break;
        }

        mapView.onCreate(savedInstanceState);
// 调用 onCreate方法 对 MapView LayoutParams 设置
        init();

    }
    private void init()
    {
        maps=mapView.getMap();
        MyLocationStyle myLocationStyle;
        myLocationStyle = new MyLocationStyle();//初始化定位蓝点样式类myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE);//连续定位、且将视角移动到地图中心点，定位点依照设备方向旋转，并且会跟随设备移动。（1秒1次定位）如果不设置myLocationType，默认也会执行此种模式。
        myLocationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_MAP_ROTATE_NO_CENTER);//连续定位、蓝点不会移动到地图中心点，地图依照设备方向旋转，并且蓝点会跟随设备移动。
        myLocationStyle.interval(2000); //设置连续定位模式下的定位间隔，只在连续定位模式下生效，单次定位模式下不会生效。单位为毫秒。
        maps.setMyLocationStyle(myLocationStyle);//设置定位蓝点的Style
        maps.getUiSettings().setMyLocationButtonEnabled(true);//设置默认定位按钮是否显示，非必需设置。
        maps.setMyLocationEnabled(true);// 设置为true表示启动显示定位蓝点，false表示隐藏定位蓝点并不进行定位，默认是false。
        final Marker marker = maps.addMarker(new MarkerOptions().position(latLng).title("hh").snippet("ok"));

        maps.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng,18));
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        //在activity执行onDestroy时执行mMapView.onDestroy()，销毁地图
        mapView.onDestroy();
    }
    @Override
    protected void onResume() {
        super.onResume();

        //在activity执行onResume时执行mMapView.onResume ()，重新绘制加载地图
        mapView.onResume();
    }
    @Override
    protected void onPause() {
        super.onPause();
        //在activity执行onPause时执行mMapView.onPause ()，暂停地图的绘制
        mapView.onPause();
    }
    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        //在activity执行onSaveInstanceState时执行mMapView.onSaveInstanceState (outState)，保存地图当前的状态
        mapView.onSaveInstanceState(outState);
    }
}

